1. Field of the Invention
The invention disclosed herein generally pertains to a method for debugging, or determining the cause of, a hang condition that has been detected in an application process. More particularly, the invention pertains to a method of the above type wherein the state of a process thread can be recovered by the debugger, for use in determining the cause of the hang condition.
2. Description of the Related Art
When an application process that has multiple threads is running on a data processing system, a “hang” condition or “hang” can occur, wherein the process becomes frozen or deadlocked and is unable to continue. A hang can occur when one of the threads is sleeping or in a sleep state, as described hereinafter in further detail.
As is well known by those of skill in the art, a debugger is a computer program used to test and debug other programs. If a program crashes and the debugger is a source level type of debugger, if can be used to determine the position of a fault or defect in the original code. Accordingly, a source level debugger may serve as a useful tool for determining programming errors in processes of the above type, wherein the errors can result in hang conditions. However, currently available source level debuggers have a serious drawback.
A debugger as described above attaches to a thread of an already running process by sending a signal to the process, causing one of the threads in the process to change its execution path to handle the signal. This thread will then recognize that the signal is on behalf of a debugger attachment request and suspend all other threads in the process. The attached thread then stops itself, waits on an event, and gives control to the debugger, so that the debugger can analyze the user mode machine state of the process which is to be debugged. However, if the process is already hung at the time that the debugger is being attached to it, a thread in the kernel that was sleeping could be the thread that received the signal and became attached to the debugger. If this happens, the sleeping thread is awakened by the debugger signal, and as a result, the reason for the hang is lost. This is because the “hung” state of the process was disturbed by letting the process handle the signal. Therefore, when the debugger that now has control of the process continues to operate the process, process execution is found to be normal, and the hang condition has been lost. The state of the process which caused the hang condition was changed or affected by the procedure of attaching the debugger to the application process.